Skip to content

fix: skip reasoningContent blocks in LlamaAPI, llama.cpp, and Writer models#2072

Open
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Zelys-DFKH:fix/skip-reasoning-content-in-multi-provider-swarms
Open

fix: skip reasoningContent blocks in LlamaAPI, llama.cpp, and Writer models#2072
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Zelys-DFKH:fix/skip-reasoning-content-in-multi-provider-swarms

Conversation

@Zelys-DFKH
Copy link
Copy Markdown

Description

In multi-provider Swarms, reasoning-capable models (e.g. Gemini, Claude) store
reasoningContent blocks in shared conversation history. When that history is
passed to LlamaAPIModel, LlamaCppModel, or WriterModel on a subsequent turn,
the content-type filter only skipped toolResult and toolUse blocks — not
reasoningContent — causing TypeError: content_type=<reasoningContent> | unsupported type.

PR #2013 fixed this for openai.py and openai_responses.py. This extends the
same fix to the three remaining affected providers by adding "reasoningContent"
to the skip list in each model's _format_request_messages (and the vision
formatter in writer.py).

Related Issues

Resolves #1993

Documentation PR

N/A

Type of Change

Bug fix

Testing

  • Added test_format_request_skips_reasoning_content to each affected model's test file
  • Removed reasoningContent from test_writer.py's test_format_request_with_unsupported_type parametrize (it is no longer unsupported — it is silently skipped)
  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…models

In multi-provider Swarms, reasoning-capable models (e.g. Gemini, Claude)
store reasoningContent blocks in shared conversation history. When that
history is passed to LlamaAPIModel, LlamaCppModel, or WriterModel, the
content-type filter only skipped toolResult and toolUse blocks — not
reasoningContent — causing a TypeError on the next turn.

Extends the fix already applied to openai.py and openai_responses.py
(PR strands-agents#2013) to the three remaining affected providers. Also removes
reasoningContent from the unsupported-type parametrize in test_writer.py
and adds a dedicated skip test to each model's test file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAIResponsesModel: reasoningContent blocks in shared history cause TypeError in multi-provider Swarms

1 participant